package com.cango.student.io.ioStudy;

import java.io.*;


public class ByteToChar {
    public static void main(String[] args) throws Exception {
//        byteToChar();
        fromSystemIn();
    }
    /**
     * 字节流转换成字符流
     */
    public static void byteToChar() throws Exception {
        try (BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream("D:\\1.txt")));
             BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream("D:\\erp-sms-web.log")))) {
            String s;
            StringBuilder sb = new StringBuilder();
            while ((s = br.readLine()) != null) {
                System.out.println(s);
                bw.write(s);
                bw.newLine();
            }
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    /**
     * 用转换流从控制台上读入数据
     * @throws Exception
     */
    public static void fromSystemIn() throws Exception {
        BufferedReader br = null;
        try {
            br = new BufferedReader(new InputStreamReader(System.in));
            String s = br.readLine();
            System.out.println(s);
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            if (null != br) {
                br.close();
            }
        }
    }

}
